<test>
  <substitutions>
    <substitution>
      <name>engine</name>
      <values>
        <value>mt</value>
        <value>rmt</value>
      </values>
    </substitution>
  </substitutions>

  <create_query>create table alter_select_mt  (part_id String, col_0 String) engine=MergeTree()                                              partition by part_id order by tuple() settings max_parts_to_merge_at_once=1</create_query>
  <create_query>create table alter_select_rmt (part_id String, col_0 String) engine=ReplicatedMergeTree('/tables/{{database}}', '{{table}}') partition by part_id order by tuple() settings max_parts_to_merge_at_once=1</create_query>

  <create_query>system stop merges alter_select_{engine}</create_query>

  <fill_query>
      insert into alter_select_{engine} (part_id, col_0)
      select toString(number % 5000), 0 from numbers(10000)
      settings
      max_block_size=1,
      max_insert_threads=32,
      min_insert_block_size_rows=1,
      insert_deduplicate=false,
      parts_to_delay_insert=100000,
      parts_to_throw_insert=100000
  </fill_query>
  <fill_query>alter table alter_select_{engine} drop column col_0 settings alter_sync = 0</fill_query>

  <query>select count() from alter_select_{engine} format Null settings max_threads=1</query>
  <query>select * from alter_select_{engine} format Null settings max_threads=1</query>

  <drop_query>drop table alter_select_{engine}</drop_query>
</test>

